* (bug 19944) Link on image thumbnails no longer link to "Media:" namespace in some...
authorAlexandre Emsenhuber <ialex@users.mediawiki.org>
Wed, 10 Nov 2010 09:16:28 +0000 (09:16 +0000)
committerAlexandre Emsenhuber <ialex@users.mediawiki.org>
Wed, 10 Nov 2010 09:16:28 +0000 (09:16 +0000)
* (bug 25670) wfFindFile() now checks the namespace of the given title, only "File" and "Media" are allowed now

The problem with bug 19944 was that the cache in RepoGroup was holding a file with a Title that has its namespace set to NS_MEDIA; the cache is now only used for title with namespace set to NS_FILE.
Also modified ImageGallery to not call wfFindFile() on non-NS_FILE title; was obviously breaking the above fix.

RELEASE-NOTES
includes/ImageGallery.php
includes/filerepo/RepoGroup.php

index 7dc2623..d0da78f 100644 (file)
@@ -416,6 +416,10 @@ LocalSettings.php. The specific bugs are listed below in the general notes.
 * (bug 17789) Added a note to the total views on Special:Statistics saying that
   is doesn't count non-existing pages and special pages
 * (bug 17996) HTTP redirects are now combined when requesting a special page
+* (bug 19944) Link on image thumbnails no longer link to "Media:" namespace in
+  some cases
+* (bug 25670) wfFindFile() now checks the namespace of the given title, only
+  "File" and "Media" are allowed now
 
 === API changes in 1.17 ===
 * (bug 22738) Allow filtering by action type on query=logevent.
index 3e6e3b9..281cac2 100644 (file)
@@ -244,9 +244,13 @@ class ImageGallery
                        $time = $descQuery = false;
                        wfRunHooks( 'BeforeGalleryFindFile', array( &$this, &$nt, &$time, &$descQuery ) );
 
-                       $img = wfFindFile( $nt, array( 'time' => $time ) );
+                       if ( $nt->getNamespace() == NS_FILE ) {
+                               $img = wfFindFile( $nt, array( 'time' => $time ) );
+                       } else {
+                               $img = false;
+                       }
 
-                       if( $nt->getNamespace() != NS_FILE || !$img ) {
+                       if( !$img ) {
                                # We're dealing with a non-image, spit out the name and be done with it.
                                $thumbhtml = "\n\t\t\t".'<div style="height: '.($this->mHeights*1.25+2).'px;">'
                                        . htmlspecialchars( $nt->getText() ) . '</div>';
index 82f7939..b999694 100644 (file)
@@ -100,10 +100,15 @@ class RepoGroup {
                        }
                }
 
+               if ( $title->getNamespace() != NS_MEDIA && $title->getNamespace() != NS_FILE ) {
+                       throw new MWException( __METHOD__ . ' recieved an Title object with incorrect namespace' );
+               }
+
                # Check the cache
                if ( empty( $options['ignoreRedirect'] )
                        && empty( $options['private'] )
-                       && empty( $options['bypassCache'] ) )
+                       && empty( $options['bypassCache'] )
+                       && $title->getNamespace() == NS_FILE )
                {
                        $useCache = true;
                        $time = isset( $options['time'] ) ? $options['time'] : '';